<!doctype html>
<html>
<head>
	<meta charset="utf-8">
	<th:block th:include="include/src :: grid_base_js_and_css"/>
	
	<style>
	html {height: 100vh;background-color: #ffffff;}
	body {height: 100vh;}
	</style>
</head>
<body>
<!-- 字段名称 -->
<script type="text/html" id="templet_script_name">
<input type="text" class="layui-input ys-input-table" name="name" value="{{d.name}}" lay-skin="input" lay-filter="_input_filter_text_on_table" lay-event="_event_text_change_on_table">
</script>
<!-- 字段编码 -->
<script type="text/html" id="templet_script_code">
<input type="text" class="layui-input ys-input-table" name="code" value="{{d.code}}" lay-skin="input" lay-filter="_input_filter_text_on_table" lay-event="_event_text_change_on_table">
</script>
<!-- 触发联动字段 -->
<script type="text/html" id="templet_script_modalRelativeCode">
<input type="text" class="layui-input ys-input-table" name="modalRelativeCode" value="{{d.modalRelativeCode}}" lay-skin="input" lay-filter="_input_filter_text_on_table" lay-event="_event_text_change_on_table">
</script>
<!-- 弹出框取值字段 -->
<script type="text/html" id="templet_script_modalValueCode">
<input type="text" class="layui-input ys-input-table" name="modalValueCode" value="{{d.modalValueCode}}" lay-skin="input" lay-filter="_input_filter_text_on_table" lay-event="_event_text_change_on_table">
</script>
<!-- 表单占据长度 -->
<script type="text/html" id="templet_script_formLength">
<select name="formLength" lay-filter="_input_filter_selector_on_table">
{{#  layui.each(MAP_DICT['YS_Col-FormLength'], function(index, item){ }}
{{# if(d.formLength == item.value){ }} <option value="{{ item.value }}" selected>{{ item.name }}</option> {{#  } else { }} <option value="{{ item.value }}">{{ item.name }}</option>  {{#  } }}
{{#  }); }}
</select>
</script>
<!-- 表单提示文字 -->
<script type="text/html" id="templet_script_formTip">
<input type="text" class="layui-input ys-input-table" name="p" value="{{d.p}}" lay-skin="input" lay-filter="_input_filter_text_on_table" lay-event="_event_text_change_on_table">
</script>
<!-- 表单是否新增 -->
<script type="text/html" id="templet_script_formAddState">
{{# if(d.formAddState === 1){ }}
<input type="checkbox" name="formAddState" value="{{d.formAddState}}" lay-skin="switch" lay-text="是|否" lay-filter="_input_filter_checkbox_on_menu_table" checked>
{{#  } else { }}
<input type="checkbox" name="formAddState" value="{{d.formAddState}}" lay-skin="switch" lay-text="是|否" lay-filter="_input_filter_checkbox_on_menu_table">
{{#  } }}
</script>
<!-- 表单新增隐藏 -->
<script type="text/html" id="templet_script_formAddHidden">
{{# if(d.formAddHidden === 1){ }}
<input type="checkbox" name="formAddHidden" value="{{d.formAddHidden}}" lay-skin="switch" lay-text="是|否" lay-filter="_input_filter_checkbox_on_menu_table" checked>
{{#  } else { }}
<input type="checkbox" name="formAddHidden" value="{{d.formAddHidden}}" lay-skin="switch" lay-text="是|否" lay-filter="_input_filter_checkbox_on_menu_table">
{{#  } }}
</script>
<!-- 表单新增类型 -->
<script type="text/html" id="templet_script_formAddType">
<select name="formAddType" lay-filter="_input_filter_selector_on_table">
{{#  layui.each(MAP_DICT['YS_Col-FormAddType'], function(index, item){ }}
{{# if(d.formAddType == item.value){ }} <option value="{{ item.value }}" selected>{{ item.name }}</option> {{#  } else { }} <option value="{{ item.value }}">{{ item.name }}</option>  {{#  } }}
{{#  }); }}
</select>
</script>
<!-- 表单新增必填 -->
<script type="text/html" id="templet_script_formAddRequired">
{{# if(d.formAddRequired === 1){ }}
<input type="checkbox" name="formAddRequired" value="{{d.formAddRequired}}" lay-skin="switch" lay-text="是|否" lay-filter="_input_filter_checkbox_on_menu_table" checked>
{{#  } else { }}
<input type="checkbox" name="formAddRequired" value="{{d.formAddRequired}}" lay-skin="switch" lay-text="是|否" lay-filter="_input_filter_checkbox_on_menu_table">
{{#  } }}
</script>
<!-- 表单新增只读 -->
<script type="text/html" id="templet_script_formAddReadonly">
{{# if(d.formAddReadonly === 1){ }}
<input type="checkbox" name="formAddReadonly" value="{{d.formAddReadonly}}" lay-skin="switch" lay-text="是|否" lay-filter="_input_filter_checkbox_on_menu_table" checked>
{{#  } else { }}
<input type="checkbox" name="formAddReadonly" value="{{d.formAddReadonly}}" lay-skin="switch" lay-text="是|否" lay-filter="_input_filter_checkbox_on_menu_table">
{{#  } }}
</script>
<!-- 表单是否编辑 -->
<script type="text/html" id="templet_script_formEditState">
{{# if(d.formEditState === 1){ }}
<input type="checkbox" name="formEditState" value="{{d.formEditState}}" lay-skin="switch" lay-text="是|否" lay-filter="_input_filter_checkbox_on_menu_table" checked>
{{#  } else { }}
<input type="checkbox" name="formEditState" value="{{d.formEditState}}" lay-skin="switch" lay-text="是|否" lay-filter="_input_filter_checkbox_on_menu_table">
{{#  } }}
</script>
<!-- 表单编辑类型 -->
<script type="text/html" id="templet_script_formEditType">
<select name="formEditType" lay-filter="_input_filter_selector_on_table">
{{#  layui.each(MAP_DICT['YS_Col-FormEditType'], function(index, item){ }}
{{# if(d.formEditType == item.value){ }} <option value="{{ item.value }}" selected>{{ item.name }}</option> {{#  } else { }} <option value="{{ item.value }}">{{ item.name }}</option>  {{#  } }}
{{#  }); }}
</select>
</script>
<!-- 表单编辑隐藏 -->
<script type="text/html" id="templet_script_formEditHidden">
{{# if(d.formEditHidden === 1){ }}
<input type="checkbox" name="formEditHidden" value="{{d.formEditHidden}}" lay-skin="switch" lay-text="是|否" lay-filter="_input_filter_checkbox_on_menu_table" checked>
{{#  } else { }}
<input type="checkbox" name="formEditHidden" value="{{d.formEditHidden}}" lay-skin="switch" lay-text="是|否" lay-filter="_input_filter_checkbox_on_menu_table">
{{#  } }}
</script>
<!-- 表单编辑必填 -->
<script type="text/html" id="templet_script_formEditRequired">
{{# if(d.formEditRequired === 1){ }}
<input type="checkbox" name="formEditRequired" value="{{d.formEditRequired}}" lay-skin="switch" lay-text="是|否" lay-filter="_input_filter_checkbox_on_menu_table" checked>
{{#  } else { }}
<input type="checkbox" name="formEditRequired" value="{{d.formEditRequired}}" lay-skin="switch" lay-text="是|否" lay-filter="_input_filter_checkbox_on_menu_table">
{{#  } }}
</script>
<!-- 表单编辑只读 -->
<script type="text/html" id="templet_script_formEditReadonly">
{{# if(d.formEditReadonly === 1){ }}
<input type="checkbox" name="formEditReadonly" value="{{d.formEditReadonly}}" lay-skin="switch" lay-text="是|否" lay-filter="_input_filter_checkbox_on_menu_table" checked>
{{#  } else { }}
<input type="checkbox" name="formEditReadonly" value="{{d.formEditReadonly}}" lay-skin="switch" lay-text="是|否" lay-filter="_input_filter_checkbox_on_menu_table">
{{#  } }}
</script>
<!-- 多文件来源类型 -->
<script type="text/html" id="templet_script_multyFileSourceType">
<select name="multyFileSourceType" lay-filter="_input_filter_selector_on_table">
{{#  layui.each(MAP_DICT['YS_Col-MultyFileSourceType'], function(index, item){ }}
{{# if(d.multyFileSourceType == item.value){ }} <option value="{{ item.value }}" selected>{{ item.name }}</option> {{#  } else { }} <option value="{{ item.value }}">{{ item.name }}</option>  {{#  } }}
{{#  }); }}
</select>
</script>
<!-- 操作 -->
<script type="text/html" id="templet_script_13">
{{#  if(d.formAddType == 't_checkbox' || d.formAddType == 't_dropdown' || d.formEditType == 't_checkbox' || d.formEditType == 't_dropdown'){ }}
<a class="layui-btn layui-btn-xs layui-btn-normal" onclick="var w=($(window).width()*0.8); var h=($(window).height() - 50); layer.open({ title:'设置选项',  type: 2,area: [w+'px', h +'px'],fix: true, maxmin: false, shadeClose: true, shade:0.4,shade:0.5,content:'/web/sys/ysCol/toSettingOption?colId={{d.id}}' });"><i class="layui-icon layui-icon-set"></i>设置选项</a>
{{#  } }}
{{#  if(d.formAddType == 't_buttontext' || d.formEditType == 't_buttontext'){ }}
<a class="layui-btn layui-btn-xs layui-btn-normal" onclick="var w=($(window).width()*0.8); var h=($(window).height() - 50); layer.open({ title:'设置前台弹出框',  type: 2,area: [w+'px', h +'px'],fix: true, maxmin: false, shadeClose: true, shade:0.4,shade:0.5,content:'/web/sys/ysCol/toSettingSelectorModal?colId={{d.id}}' });"><i class="layui-icon layui-icon-set"></i>设置弹出框</a>
{{#  } }}
{{#  if(d.formAddType == 't_dropdown_multy' || d.formEditType == 't_dropdown_multy'){ }}
<a class="layui-btn layui-btn-xs layui-btn-normal" onclick="var w=($(window).width()*0.8); var h=($(window).height() - 50); layer.open({ title:'设置下拉框(多选)',  type: 2,area: [w+'px', h +'px'],fix: true, maxmin: false, shadeClose: true, shade:0.4,shade:0.5,content:'/web/sys/ysCol/toSettingDropdownMulty?colId={{d.id}}' });"><i class="layui-icon layui-icon-set"></i>设置下拉框</a>
{{#  } }}
{{#  if(d.formAddType == 't_file_multy' || d.formEditType == 't_file_multy'){ }}
<a class="layui-btn layui-btn-xs layui-btn-normal" onclick="var w=($(window).width()*0.8); var h=($(window).height() - 50); layer.open({ title:'设置文件来源类型',  type: 2,area: [w+'px', h +'px'],fix: true, maxmin: false, shadeClose: true, shade:0.4,shade:0.5,content:'/web/sys/ysCol/toSettingMultyFileSourceType?colId={{d.id}}' });"><i class="layui-icon layui-icon-set"></i>设置文件来源</a>
{{#  } }}
<a class="layui-btn layui-btn-xs layui-btn-danger" onclick="doDeleteOnTable('/api/inter/ysCol/deleteTrue?id={{d.id}}');"><i class="layui-icon layui-icon-delete"></i>删除</a>
</script>
	<div class="display_flex" style="height: 100%;" id="id_panel_content">
	</div>
	
	<script type="text/html" id="toolbarDemo">
	<div class="layui-btn-container">
		<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="event-grid-add-row"><i class="iconfont icon-add-btn"></i>新增单个字段</a>
		<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="event-grid-add-rows"><i class="iconfont icon-add-btn"></i>批量新增字段</a>
	</div>
	</script>
	
	<script th:inline="javascript">
	var cols = [
	            [
	             {
	                 "title": "",
	                 "type": "checkbox",
	                 "fixed": "left",
	                 "unresize": true,
	                 "width": "40",
	                 "colGroup": false
	             },
	             {
	                 "title": "序号",
	                 "fixed": "left",
	                 "unresize": true,
	                 "width": "50",
	                 "align": "center",
	                 "type": "numbers"
	             },
	             {
	                 "title": "字段ID",
	                 "field": "id",
	                 "fixed": "left",
	                 "width": "80",
	                 "align": "center",
	                 "sort": true,
	                 "type": "normal"
	             },
	             {
	                 "title": "字段名称",
	                 "field": "name",
	                 "fixed": "left",
	                 "width": "160",
	                 "align": "center",
	                 "sort": true,
	                 "type": "normal",
	                 "templet": '#templet_script_name'
	             },
	             {
	                 "title": "字段编码",
	                 "field": "code",
	                 "fixed": "left",
	                 "width": "200",
	                 "align": "center",
	                 "sort": true,
	                 "type": "normal",
	                 "templet": '#templet_script_code'
	             },
	             {
	                 "title": "触发联动字段",
	                 "field": "modalRelativeCode",
	                 "width": "120",
	                 "align": "center",
	                 "sort": true,
	                 "type": "normal",
	                 "templet": '#templet_script_modalRelativeCode'
	             },
	             {
	                 "title": "弹出框取值字段",
	                 "field": "modalValueCode",
	                 "width": "120",
	                 "align": "center",
	                 "sort": true,
	                 "type": "normal",
	                 "templet": '#templet_script_modalValueCode'
	             },
	             {
	                 "title": "表单占据长度",
	                 "field": "formLength",
	                 "width": "100",
	                 "align": "center",
	                 "sort": true,
	                 "type": "normal",
	                 "templet": '#templet_script_formLength'
	             },
	             {
	                 "title": "表单提示文字",
	                 "field": "formTip",
	                 "width": "120",
	                 "align": "center",
	                 "sort": true,
	                 "type": "normal",
	                 "templet": '#templet_script_formTip'
	             },
	             {
	                 "title": "表单是否新增",
	                 "field": "formAddState",
	                 "width": "120",
	                 "align": "center",
	                 "sort": true,
	                 "type": "normal",
	                 "templet": '#templet_script_formAddState'
	             },
	             {
	                 "title": "表单新增隐藏",
	                 "field": "formAddHidden",
	                 "width": "120",
	                 "align": "center",
	                 "sort": true,
	                 "type": "normal",
	                 "templet": '#templet_script_formAddHidden'
	             },
	             {
	                 "title": "表单新增类型",
	                 "field": "formAddType",
	                 "width": "120",
	                 "align": "center",
	                 "sort": true,
	                 "type": "normal",
	                 "templet": '#templet_script_formAddType'
	             },
	             {
	                 "title": "表单新增必填",
	                 "field": "formAddRequired",
	                 "width": "120",
	                 "align": "center",
	                 "sort": true,
	                 "type": "normal",
	                 "templet": '#templet_script_formAddRequired'
	             },
	             {
	                 "title": "表单新增只读",
	                 "field": "formAddReadonly",
	                 "width": "120",
	                 "align": "center",
	                 "sort": true,
	                 "type": "normal",
	                 "templet": '#templet_script_formAddReadonly'
	             },
	             {
	                 "title": "表单是否编辑",
	                 "field": "formEditState",
	                 "width": "120",
	                 "align": "center",
	                 "sort": true,
	                 "type": "normal",
	                 "templet": '#templet_script_formEditState'
	             },
	             {
	                 "title": "表单编辑类型",
	                 "field": "formEditType",
	                 "width": "120",
	                 "align": "center",
	                 "sort": true,
	                 "type": "normal",
	                 "templet": '#templet_script_formEditType'
	             },
	             {
	                 "title": "表单编辑隐藏",
	                 "field": "formEditHidden",
	                 "width": "120",
	                 "align": "center",
	                 "sort": true,
	                 "type": "normal",
	                 "templet": '#templet_script_formEditHidden'
	             },
	             {
	                 "title": "表单编辑必填",
	                 "field": "formEditRequired",
	                 "width": "120",
	                 "align": "center",
	                 "sort": true,
	                 "type": "normal",
	                 "templet": '#templet_script_formEditRequired'
	             },
	             {
	                 "title": "表单编辑只读",
	                 "field": "formEditReadonly",
	                 "width": "120",
	                 "align": "center",
	                 "sort": true,
	                 "type": "normal",
	                 "templet": '#templet_script_formEditReadonly'
	             },
	             {
	                 "title": "多文件来源类型",
	                 "field": "multyFileSourceType",
	                 "width": "160",
	                 "align": "center",
	                 "sort": true,
	                 "type": "normal",
	                 "templet": '#templet_script_multyFileSourceType'
	             },
	             {
	                 "title": "操作",
	                 "field": "ope",
	                 "fixed": "right",
	                 "width": "300",
	                 "align": "center",
	                 "sort": true,
	                 "type": "normal",
	                 "templet": "#templet_script_13"
	             }
	         ]
	     ];
	// 搜索表单初始化
	var gridObj = null;
	//使用layui的模块
	layui.config({
		//自定义layui组件的目录,设定扩展的layui模块的所在目录，一般用于外部模块扩展
		base: '/static/js/layui_extends/'
	}).use(['form', 'jquery', 'element', 'table', 'dropdown', 'optimizeSelectOption', 'util', 'laydate', 'YsGridOfMainTable', 'YsModal'], function(){
		var $ = layui.jquery;
		var dropdown = layui.dropdown;
		var element = layui.element;
		var form = layui.form;
		var laydate = layui.laydate;
		var table = layui.table;
		var util = layui.util;
		var YsGridOfMainTable = layui.YsGridOfMainTable;
		gridObj = YsGridOfMainTable.init({
			id_panel_content: 'id_panel_content',
			conditions: [],
			menuId: [(${id})], // 菜单ID
			templateType: 'normal_list', // 模板类型，见ENUM
			pathGridRequest: '/api/inter/ysCol/search?menuId=[(${id})]', // 表格数据请求地址
			pathGridEditRequest: '/api/inter/common/editOnTable?menuId=12', // 表格上编辑提交地址
			cols: cols
		});
	});
	
	// 在表格上修改
	function doEditOnTable(dataCommit) {
		var indexOfLoading = layer.load(1, {
			shade: [0.5,'#000000'] //0.1透明度的白色背景
		});
		$.post('/api/inter/common/editOnTable?menuId=[(${id})]', dataCommit, function(res){
			if (res.code == 0) {
				layer.msg(res.msg);
				layer.close(indexOfLoading);
			} else {
				layer.close(indexOfLoading);
				layer.msg(res.msg);
			}
		});
	}
	
	// 调整鼠标移动到每行数据时的样式
	$('body').on("mouseenter",".layui-table-body tr",function () {
	    $(this).siblings().find("div").css("color","#142A48");
	    $(this).find("div").css("color","#4DA1FF");
	})
	</script>
</body>
</html>